
var DataMgr = require('DataMgr');
cc.Class({
    extends: cc.Component,

    properties: {

        _resurrection_view: fgui.GComponent,

        _integral_view: fgui.GLabel,

        _level_Label: fgui.GLabel,
        
    },

    // LIFE-CYCLE CALLBACKS:
    // use this for initialization

    onLoad: function () {
        fgui.addLoadHandler();

        fgui.GRoot.create();

        fgui.UIPackage.loadPackage("UI/IMGame", this.onUILoaded.bind(this));
    },

    onUILoaded: function () {
        fgui.UIPackage.addPackage("UI/IMGame");

        _resurrection_view = fgui.UIPackage.createObject("IMGame", "ResurrectionPanel").asCom;
        _resurrection_view.makeFullScreen();


          //积分
          _resurrection_view.getChild("n12").onClick(this.onResurrectionClick, this);
          _resurrection_view.getChild("n15").onClick(this.onGiveUpClick, this);
          _level_Label = _resurrection_view.getChild("n6");
          _level_Label.text = "LEVEL" + DataMgr.currentLevel;
  
          fgui.GRoot.inst.addChild(_resurrection_view);
        // this.loadRootUI();

    },




    loadRootUI: function () {
        //积分
        _resurrection_view.getChild("n12").onClick(this.onResurrectionClick, this);
        _resurrection_view.getChild("n15").onClick(this.onGiveUpClick, this);

        fgui.GRoot.inst.addChild(_resurrection_view);
    },


     //点击复活按钮
     onResurrectionClick:function(){
        // console.log("onResurrectionClick");
        cc.director.loadScene('game');
        // _resurrection_view.removeFromParent();
    },

    //点击放弃按钮
    onGiveUpClick:function(){
        cc.sys.localStorage.setItem('level', 1);
        DataMgr.reset();
        cc.director.loadScene('start');
        // console.log("onGiveUpClick");
    },

    start() {

    },

    // update (dt) {},
});
